import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {createSvgIconsPlugin} from 'vite-plugin-svg-icons'
import path from "path";

// https://vite.dev/config/
export default defineConfig({
	server: {
		proxy: {
			"/api": {
				target: 'http://127.0.0.1:9999', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ""),
			},
		},
	}, transpileDependencies: true, lintOnSave: false, devServer: {
		port: 9654, // 设置开发服务器的端口为 9654
		proxy: {
			'/api': {
				target: 'http://127.0.0.1:9999', changeOrigin: true, pathRewrite: {'^/api': ''}
			}
		},
	}, resolve: {
		alias: {
			"@": path.resolve(__dirname, "./src"),
		},
	}, plugins: [vue(), createSvgIconsPlugin({
		// 指定需要缓存的图标文件夹
		iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], // 指定symbolId格式
		symbolId: 'icon-[dir]-[name]', /**
		 * 自定义插入位置
		 * @default: body-last
		 */
		// inject? : 'body-last' | 'body-first'

		/**
		 * custom dom id
		 * @default: __svg__icons__dom__
		 */
		customDomId: '__svg__icons__dom__',
	}),]
})
